home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 264_01 / getdir.asm < prev    next >
Assembly Source File  |  1980-01-01  |  2KB  |  80 lines

  1. ; getdir.asm
  2. ; Works with Aztec C v3.20d.
  3.  
  4. codeseg segment para public 'code'
  5. dataseg segment para public 'data'
  6. dataseg ends
  7.     assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg
  8.  
  9. codeseg segment
  10.  
  11. ; int setdta(char *buf)
  12. ; Set the disk transfer address to the address pointed to by the argument.
  13. ; Gives the getfirst_ and getnext_ routines a user-defined buffer where
  14. ; filenames are accessible.
  15.  
  16.     PUBLIC  setdta_
  17. setdta_     PROC NEAR
  18.     push    bp
  19.     mov     bp,sp
  20.     mov     dx,[bp+4]               ; offset of disk transfer address
  21.     mov     ah,1Ah                  ; ms-dos set dta
  22.     int     21h
  23.     mov     sp,bp
  24.     pop     bp
  25.     ret 
  26. setdta_     ENDP
  27.  
  28. ; int getfirst(char *path, int attributes)
  29. ; First argument points to a string with an MSDOS file specification
  30. ; (possibly containing wildcards).  Second argument is a mask of attributes
  31. ; that files must match.  Calls the MSDOS "find first file" function to find
  32. ; a filename that matches the file spec.
  33. ; Returns 0 on success, non-zero on failure.
  34.  
  35.     PUBLIC  getfirst_
  36. getfirst_   PROC NEAR
  37.     push    bp
  38.     mov     bp,sp
  39.     mov     dx,[bp+4]               ; offset of string with pathname
  40.     mov     cx,[bp+6]               ; attributes to match
  41.     mov     ah,4Eh                  ; ms-dos find first file
  42.     int     21h
  43.     jc      gf_err
  44.     mov     ax,0
  45.     jmp     gf_end
  46. gf_err:
  47.     mov     ax,1
  48. gf_end:
  49.     mov     sp,bp
  50.     pop     bp
  51.     ret 
  52. getfirst_   ENDP
  53.  
  54. ; int getnext(char *path, int attributes)
  55. ; Same as getfirst_, except uses the MSDOS "find next file" function.
  56.  
  57.     PUBLIC  getnext_
  58. getnext_    PROC NEAR
  59.     push    bp
  60.     mov     bp,sp
  61.     mov     dx,[bp+4]               ; offset of string with pathname
  62.     mov     cx,[bp+6]               ; attributes to match
  63.     mov     ah,4Fh                  ; ms-dos find next file
  64.     int     21h
  65.     jc      gn_err
  66.     mov     ax,0
  67.     jmp     gn_end
  68. gn_err:
  69.     mov     ax,1
  70. gn_end:
  71.     mov     sp,bp
  72.     pop     bp
  73.     ret 
  74. getnext_    ENDP
  75.     
  76. codeseg ends
  77. dataseg segment para public 'data'
  78. dataseg ends
  79.     end
  80.